﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Zinnia.Lite.Untilty;

namespace Zinnia.Lite.WinformTest
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                MessageBox.Show(GetRootPath());
                MessageBox.Show(FileHelper.Instance.ReadFileText("/test.txt"));
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                MessageBox.Show("OK");
            }
        }
        private string GetRootPath()
        {
            string baseDirectory = AppDomain.CurrentDomain.BaseDirectory;
            int binPos = baseDirectory.IndexOf("bin"); //找不到-1
            if (binPos < 0)
                return baseDirectory;
            return baseDirectory.Substring(0, binPos);
        }
    }
}
